import matplotlib.pyplot as plt
import cv2
import lasio
import pandas as pd


def DrawLinesAndGetImg(las):
    # 创建一个新的图形
    fig, axs = plt.subplots(1, 9, figsize=(20, 10), sharey=True)

    # 获取伽马数据的索引
    gamma_keys = ['AGRM', 'AGR0', 'AGR1', 'AGR2', 'AGR3', 'AGR4', 'AGR5', 'AGR6', 'AGR7']
    gamma_indices = [las.keys().index(key) for key in gamma_keys if key in las.keys()]

    # 绘制每一道伽马数据
    for i, idx in enumerate(gamma_indices):
        ax = axs[i]
        ax.plot(las.data[:, idx], las.index, label=las.keys()[idx])
        ax.set_xlabel(las.keys()[idx])
        ax.xaxis.tick_top()
        ax.invert_yaxis()
        ax.grid(True)

    # 设置公共的Y轴标签
    axs[0].set_ylabel('Depth (m)')

    # 调整子图间距
    plt.tight_layout()

    # 保存图像
    plt.savefig("asset/gammaLines.png")

    return




